/*
 * 作者：姚俊
 * 功能：专利主页面显示的action
 * 日期：2015-05-22
 */
package admin.action.fruits;
import java.util.*;

import admin.service.fruits.PatentService;

import com.opensymphony.xwork2.ActionContext;

import teacher.bean.Patent;
import teacher.service.patent;

public class PatentAction {
	
	private List<Patent> patents;
	//当前页
	private int currentPage;
	//最后一页
	private int endPage;
	private int counts;
	private int flag;

	public List<Patent> getPatents() {
		return patents;
	}

	public void setPatents(List<Patent> patents) {
		this.patents = patents;
	}
	
	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getEndPage() {
		return endPage;
	}

	public void setEndPage(int endPage) {
		this.endPage = endPage;
	}

	public int getFlag() {
		return flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}
	
	public int getCounts() {
		return counts;
	}

	public void setCounts(int counts) {
		this.counts = counts;
	}

	public String execute()
	{
		
		//当当前页为零的时候，把当前页变成1
		if(this.getCurrentPage()==0)
			this.setCurrentPage(1);
		
		int add=0;
		if(new patent().getCountPatent()%Constant.pageSize!=0)
		{
			add=1;
		}
		//最后一页
		this.setEndPage(new patent().getCountPatent()/Constant.pageSize+add);
		this.setCounts(new patent().getCountPatent());
		ActionContext.getContext().put("flag", 0);
		this.setFlag(0);
		//调用查询所有专利的方法
		patents=new PatentService().getSegregatePatentByAll(
				(this.getCurrentPage()-1)*Constant.pageSize+1, Constant.pageSize);
		return "succ";
	}

}
